package com.group3.exception;

import com.group3.utils.Result;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.ToString;

@Data
@ToString
@ApiModel(value = "自定义异常类")
public class BusinessException extends RuntimeException{

    private Integer code;

    private String msg;

    public BusinessException(Integer code, String msg) {
        super();
        this.code = code;
        this.msg = msg;
    }

    public BusinessException(Result result) {
        super();
        this.code = result.getCode();
        this.msg = result.getMsg();
    }

    public BusinessException(ExceptionEnum exceptionEnum) {
        super();
        this.code = exceptionEnum.getCode();
        this.msg = exceptionEnum.getMsg();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

}